<%@ page contentType="text/html;charset=UTF-8" %>
<div class="bjui-pageContent">
    <table id="workFlow" class="table table-bordered">
        <thead>
        <tr>
            <td align="center">方法名称</td>
            <td colspan="2" align="center">参数</td>
            <td align="center">返回值</td>
        </tr>
        </thead>
        <tbody id="tbody_workFlow">
        </tbody>
    </table>
</div>
<script type="text/javascript">
    var workFlowId = "${workFlowId}";
    var searchName = decodeURIComponent(workFlowId);

    $(function () {
        BJUI.ajax('doajax', {
            url: '/admin/workFlow/findOneByName?workFlowId='+searchName,
            data: {pageCurrent: 1, pageSize: 10},
            dataType: 'json',
            okCallback: function (json) {
                var trs = BJUI.StrBuilder();
                $.each(json, function (i, n) {
                    trs.add('<tr><td rowspan="' + n.param.length * 2 + '" align="center">')
                        .add(n.name).add('</td><td align="center">')
                        .add('键').add('</td><td align="center">')
                        .add('值').add('</td><td rowspan="' + n.param.length * 2 + '" align="center">')
                        .add('<a href="javascript:;" onclick="resultDialog(\'' + encodeURIComponent(n.result) + '\')">查看返回结果</a>').add('</td></tr>');

                    var trs2 = BJUI.StrBuilder();
                    $.each(n.param, function (ii, nn) {
                        trs2.add('<tr><td align="center">' + nn.key + '</td>').add('<td align="center"><a href="javascript:;" onclick="paramValueDialog(\'' + encodeURIComponent(nn.value) + '\')">查看值</a></td><tr>');
                    });
                    trs.add(trs2.toString());
                });
                $('#tbody_workFlow').html(trs.toString());
            }
        })
    });

    function paramValueDialog(paramValue) {

        var result = decodeURIComponent(paramValue);
        if(!result){
            alert("传入参数为空!");
            return false;
        }

        BJUI.dialog({
            id: "info_" + new Date().getTime(),
            type:'POST',
            url: '/admin/workFlow/showPage',
            data:{"result":paramValue},
            title: "参数值详情",
            width: 800,
            height: 1200 * 0.618
        });
    }

    function resultDialog(resultValue) {

        var result = decodeURIComponent(resultValue);
        if(!result){
            alert("返回值为空!");
            return false;
        }
        BJUI.dialog({
            id: "info_" + new Date().getTime(),
            type:'POST',
            url: '/admin/workFlow/showPage',
            data:{"result":resultValue},
            title: "返回值详情",
            width: 800,
            height: 1200 * 0.619
        });
    }
</script>